import { useInfoStore } from '@/stores'
export function getCode() {
  const { setProfile } = useInfoStore()
  uni.login({
    success: (res) => {
      console.log(res, 'res')
      setProfile('loginCode', res.code)
    },
  })
}

// 延迟加载
export const sleep = () => {
  return new Promise<void>((resolve) => {
    setTimeout(() => {
      resolve()
    }, 1000)
  })
}

/**
 * @description 电话号码校验
 * @param {string} val 手机号
 */
export function checkPhone(val: string) {
  const reg = /^1[3456789][0-9]\d{8}$/
  return reg.test(String(val).trim())
}
